﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HiLand.Utility.Enums.OP;
using HySoft.Cash.Structure;

namespace PayRoller.UControls
{
    public partial class DDLCapitalFlowingDirections : System.Web.UI.UserControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (this.IsPostBack == false)
            {
                this.BindInformation();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void BindInformation()
        {
            this.DropDownList.DataSource = new EnumDataSource<CapitalFlowingDirections>(this.displaySerialName);
            this.DropDownList.DataValueField = "Value";
            this.DropDownList.DataTextField = "DisplayValue";
            this.DropDownList.DataBind();

            if (this.isDisplayEmptyItem == true)
            {
                ListItem item = new ListItem("Please Choose...", "-1");
                this.DropDownList.Items.Insert(0, item);
            }
        }

        private bool isDisplayEmptyItem = true;
        /// <summary>
        /// 是否显示"请选择..."选项
        /// </summary>
        public bool IsDisplayEmptyItem
        {
            get { return this.isDisplayEmptyItem; }
            set { this.isDisplayEmptyItem = value; }
        }

        public string SelectedValue
        {
            get { return this.DropDownList.SelectedValue; }
            set { this.DropDownList.SelectedValue = value; }
        }

        private string displaySerialName = "Display";
        /// <summary>
        /// 显示的名称所属的系列
        /// </summary>
        public string DisplaySerialName
        {
            set
            {
                this.displaySerialName = value;
            }
        }
    }
}